#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

void handler(int signo)
{
  printf("get a signal:%d\n", signo);
  printf("catch success!\n");
  exit(0);
}

int main()
{
  signal(SIGINT, handler);
  sigset_t set, oset;
  sigemptyset(&set);
  sigemptyset(&oset);
  sigaddset(&set, 2);

  printf("begin to block\n");
  sigprocmask(SIG_BLOCK, &set, &oset);
  printf("block success!\n");
  sleep(5);

  printf("\nrecover success!\n");
  sigprocmask(SIG_SETMASK, &oset, NULL);
  while(1);
  return 0;
}
